package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.BaseDataObject;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.SharedPreferencesUtil;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.HashMap;
import okhttp3.Call;

public class PassWordActivity extends BaseActivity
{
  private String TAG = "-PassWordActivity-";
  private ImageView btn_modify_psw;
  private Context context;
  private EditText edit_confirm_psw;
  private EditText edit_new_psw;
  private EditText edit_old_psw;
  private String guid = "";
  private ImageView iv_title_right;
  private int memberid;
  private MyDialog1 myDialog1;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
        PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_old_psw);
        PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_new_psw);
        PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_confirm_psw);
        CustomApplication.app.finishActivity(PassWordActivity.this);
        return;
      case 2131099914:
      }
      PassWordActivity.this.postPassword();
    }
  };
  private View view_title;

  private void init()
  {
    this.btn_modify_psw = ((ImageView)findViewById(2131099914));
    this.edit_old_psw = ((EditText)findViewById(2131099757));
    this.edit_new_psw = ((EditText)findViewById(2131099758));
    this.edit_confirm_psw = ((EditText)findViewById(2131099913));
    this.btn_modify_psw.setOnClickListener(this.onClickListener);
  }

  private void postPassword()
  {
    String str1 = CustomApplication.app.preferencesUtil.getValue(AppConstants.LOGIN_PWD, "");
    String str2 = this.edit_old_psw.getText().toString();
    final String str3 = this.edit_new_psw.getText().toString();
    String str4 = this.edit_confirm_psw.getText().toString();
    if ("".equals(str2))
    {
      ShowDialog1("请输入您的原密码");
      return;
    }
    if (!str2.equals(str1))
    {
      ShowDialog1("原密码输入错误");
      return;
    }
    if ("".equals(str3))
    {
      ShowDialog1("请输入您的新密码");
      return;
    }
    if (!UiUtil.isValidUserName(str3))
    {
      ShowDialog1("密码需要6~12位字符或数字");
      return;
    }
    if ("".equals(str4))
    {
      ShowDialog1("请输入确认密码");
      return;
    }
    if (!str3.equals(str4))
    {
      ShowDialog1("密码输入不一致，请重新输入");
      return;
    }
    if (CustomApplication.app.userBaseBean != null)
      this.guid = CustomApplication.app.userBaseBean.getGuid();
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    HashMap localHashMap = new HashMap();
    localHashMap.put("oldpwd", str2);
    localHashMap.put("newpwd", str3);
    localHashMap.put("confirmpwd", str4);
    localHashMap.put("guid", this.guid);
    localHashMap.put("Session-Token", this.memberid + "|" + "1023");
    LogUtils.e(this.TAG, "oldpwd:" + str2);
    LogUtils.e(this.TAG, "newpwd:" + str3);
    LogUtils.e(this.TAG, "confirmpwd:" + str4);
    LogUtils.e(this.TAG, "guid:" + this.guid);
    setChangeBtnIsEnable(false);
    RequestNet.get(this.context, AppConstants.URL_CHANGE_PSW, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        PassWordActivity.this.setChangeBtnIsEnable(true);
        LogUtils.e("返回失败", "result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        PassWordActivity.this.setChangeBtnIsEnable(true);
        Gson localGson = new Gson();
        try
        {
          localBaseDataObject = (BaseDataObject)localGson.fromJson(paramAnonymousString, BaseDataObject.class);
          if (localBaseDataObject == null)
          {
            PassWordActivity.this.ShowDialog1("修改失败");
            return;
          }
        }
        catch (Exception localException)
        {
          BaseDataObject localBaseDataObject;
          do
          {
            while (true)
            {
              localException.printStackTrace();
              localBaseDataObject = null;
            }
            if (localBaseDataObject.getFlag() == 0)
            {
              PassWordActivity.this.ShowDialog1(localBaseDataObject.getMsg());
              return;
            }
            if (localBaseDataObject.getFlag() == -2)
            {
              PassWordActivity.this.showDownWireDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -3)
            {
              PassWordActivity.this.ShowFengjinDialog();
              return;
            }
            if (localBaseDataObject.getFlag() == -4)
            {
              PassWordActivity.activityStack.backToMain(MainActivity.class, PassWordActivity.this.context);
              return;
            }
          }
          while (localBaseDataObject.getFlag() != 1);
          PassWordActivity.this.myDialog1.setMessage(localBaseDataObject.getMsg());
          PassWordActivity.this.myDialog1.show();
          PassWordActivity.this.myDialog1.btn_confirm.setOnClickListener(new View.OnClickListener()
          {
            public void onClick(View paramAnonymous2View)
            {
              PassWordActivity.this.myDialog1.dismiss();
              PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_old_psw);
              PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_new_psw);
              PassWordActivity.this.closeWindowSoftInput(PassWordActivity.this.edit_confirm_psw);
              CustomApplication.app.finishActivity(PassWordActivity.class);
            }
          });
          CustomApplication.app.preferencesUtil.setValue(AppConstants.LOGIN_PWD, str3);
        }
      }
    });
  }

  private void setChangeBtnIsEnable(boolean paramBoolean)
  {
    if (paramBoolean)
      this.btn_modify_psw.setBackgroundResource(2130838302);
    while (true)
    {
      this.btn_modify_psw.setEnabled(paramBoolean);
      return;
      this.btn_modify_psw.setBackgroundResource(2130838091);
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903072);
    CustomApplication.app.addActivity(this);
    this.context = this;
    setTitle(8, 0, 2130837809, "修改登录密码", 0, 8, 8, 0, true);
    init();
    this.myDialog1 = new MyDialog1(this.context);
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.edit_old_psw);
    closeWindowSoftInput(this.edit_new_psw);
    closeWindowSoftInput(this.edit_confirm_psw);
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.PassWordActivity
 * JD-Core Version:    0.6.2
 */